package com.weixin.tool;

import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class GsonFactory {

	private static GsonBuilder gsonBuilder = new GsonBuilder();
	
	static{
		gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);		
	}

	public static <T> T createObjcet(String string, Class<T> clazz) {
		Gson gson = gsonBuilder.create();
		T object = gson.fromJson(string, clazz);
		return object;
	} 
	
	public static String parseObject(Object obj){
		Gson gson = gsonBuilder.create();
		return gson.toJson(obj);
	}

}
